package com.icesoft.xsnow.cloud.gateway.filter;

import jdk.nashorn.internal.objects.Global;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @program: xsnow
 * @description: 鉴权过滤器
 * @author: xuefeng.gao
 * @create: 2019-05-06 16:28
 **/
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@Slf4j
public class AuthFilter implements GlobalFilter,Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("----------AuthFilter-------------");
        log.info("exchange.getRequest().getPath().contextPath().value();{0}",exchange.getRequest().getPath().contextPath().value());
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
